package edu.luc.cs.trull.demo.bsh.helloworld;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import bsh.EvalError;
import bsh.Interpreter;

/*
 * HelloWorldBSH by GKT...
 * 
 * This is an example of how to use the BeanShell to make Trull Scriptable.
 * This is a consoleless example of how to embed the BSH Interpreter, which
 * is the way to go when non-interactive shell use is intended.
 * 
 * We'll obviously want to have a general-purpose class to run any example 
 * but this is intended as a solid proof of concept to get us going!
 */
public class HelloWorldBSH {
	
	public static void main(String[] args) throws EvalError, FileNotFoundException, IOException {
		Interpreter shell = new Interpreter();
		File f = new File("demo/edu/luc/cs/trull/demo/bsh/helloworld/HelloWorld.bsh");
		if (f.exists()) {
			String path = f.getAbsolutePath();
			shell.source(path);
		} else {
			System.out.println("Sorry, cannot find HelloWorld.bsh");
		}
	}
}
